import axios from "axios";

const request = axios.create({
  baseURL: "https://api-hmugo-web.itheima.net",
  timeout: 5000,
});

request.interceptors.request.use(
  function (config) {
    return config;
  },
  function (error) {
    return Promise.reject(error);
  }
);

request.interceptors.response.use(
  function (response) {
    if (response.status === 200) {
      return response.data;
    }
  },
  function (error) {
    return Promise.reject(error);
  }
);

export default request;
